package com.qf.servlet;

import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.service.impl.UserServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/userActive")
public class userActiveServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request , HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding ( "utf-8" );
        String code = request.getParameter ( "code" );
        System.out.println (code );

        request.setAttribute ( "code",code );

        UserService userService = new UserServiceImp ();
        User user = userService.getUserByCode ( code );

        if (user!=null){
            request.setAttribute("msg","恭喜您,用户激活成功,<a href='/aaa_war/jsp/login.jsp'>请登录</a>");
            request.getRequestDispatcher("/jsp/msg.jsp").forward(request,response) ;
        }



    }

    protected void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException, IOException {
    doPost ( request,response );
    }
}
